#include <stdio.h>
#include <stdlib.h>

int
gcd(const int a, const int b)
{
	if (a == 0) return b;
	return gcd(b % a, a);
}

int
main(void)
{
	int p, q;
	int n, m;
	int cd;

	scanf("%d%d", &p, &q);
	n = p;
	m = q;

	while (cd = gcd(n, m), cd != 1) {
		n /= cd;
		m /= cd;
	}

	if (m < 0) {
		n *= -1;
		m *= -1;
	}
	printf("%d %d\n", n, m);

	return 0;
}
